home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / misc / emu / arosdev.lha / AROS / scripts / makelinks < prev    next >
Text File  |  1996-10-25  |  843b  |  46 lines

  1. #!/bin/sh
  2. # $0 from to filter
  3.  
  4. scriptdir="`dirname $0`"
  5.  
  6. from="$1"
  7. to="$2"
  8. if [ -z "$3" ]; then
  9.     tfilter="*"
  10. else
  11.     tfilter="$3"
  12. fi
  13.  
  14. filter="`gawk 'BEGIN { \
  15.     str=ARGV[1]; \
  16.     gsub (/\\./, "\\\\.", str); \
  17.     gsub(/\\*/,".*",str); \
  18.     print str; \
  19. }' $tfilter`"
  20.  
  21. echo -n "Creating links from $from/ to $to/ "
  22.  
  23. noglob=1
  24. echo "$tfilter"
  25. unset noglob
  26.  
  27. for direntry in $from/* ; do
  28.     entry="`basename $direntry`"
  29.     if [ -d $direntry ]; then
  30.     if [ "$entry" != "CVS" ]; then
  31.         if [ ! -d "$to/$entry" ]; then
  32.         mkdir "$to/$entry"
  33.         fi
  34.         $0 "$direntry" "$to/$entry" "$tfilter"
  35.     fi
  36.     else
  37.     if echo "$entry" | egrep -q -e "$filter"; then
  38.         rp="`$scriptdir/relpath $to $from`"
  39.         #echo "Link $from/$entry to $to/$entry"
  40.         #echo "Link $rp/$entry to $entry"
  41.         ( cd $to ; rm -f $entry ; ln -s $rp/$entry $entry )
  42.     fi
  43.     fi
  44. done
  45.  
  46.